package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"strings"
)

const ifcfgens33 = `TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=3019f77e-cb97-46a7-a73b-96d6df2c0977
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.88.75
NETMASK=255.255.0.0
GATEWAY=192.168.2.1`


      


func main(){
   
   if len(os.Args) < 5 {

	   fmt.Println("please input Ether interface Name ip netmask ")
	   return 
   }
   name:= os.Args[1]
   ip:= os.Args[2]
   netmask:= os.Args[3]
   gateway:= os.Args[4]

   nameChange := strings.Replace(ifcfgens33, "ens33", name ,-1)
   ipChange := strings.Replace(nameChange, "192.168.88.75", ip ,-1)
   maskChange := strings.Replace(ipChange, "255.255.0.0", netmask ,-1)
   gatewayChange := strings.Replace(maskChange, "192.168.2.1", gateway ,-1)

  

   ioutil.WriteFile("ifcfg-"+os.Args[1],[]byte(gatewayChange),0666)
   

   fmt.Println("ok")

}

